home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 April / macformat-049.iso / mac / Shareware Plus / Developers / dropg++ / usr / include / stand / stand.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.9 KB  |  108 lines  |  [TEXT/R*ch]

  1. /*-
  2.  * Copyright (c) 1993
  3.  *    The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)stand.h    8.1 (Berkeley) 6/11/93
  34.  */
  35.  
  36. #include <sys/types.h>
  37. #include <sys/cdefs.h>
  38. #include <sys/errno.h>
  39. #include <sys/stat.h>
  40. #include <stand/saioctl.h>
  41.  
  42. #define    UNIX    "/vmunix"
  43.  
  44. #ifndef NULL
  45. #define    NULL    0
  46. #endif
  47.  
  48. extern int errno;
  49.  
  50. struct open_file;
  51.  
  52. /*
  53.  * This structure is used to define file system operations in a file system
  54.  * independent way.
  55.  */
  56. struct fs_ops {
  57.     int    (*open) __P((char *path, struct open_file *f));
  58.     int    (*close) __P((struct open_file *f));
  59.     int    (*read) __P((struct open_file *f, char *buf,
  60.             u_int size, u_int *resid));
  61.     int    (*write) __P((struct open_file *f, char *buf,
  62.             u_int size, u_int *resid));
  63.     off_t    (*seek) __P((struct open_file *f, off_t offset, int where));
  64.     int    (*stat) __P((struct open_file *f, struct stat *sb));
  65. };
  66.  
  67. extern struct fs_ops file_system[];
  68.  
  69. /* where values for lseek(2) */
  70. #define    SEEK_SET    0    /* set file offset to offset */
  71. #define    SEEK_CUR    1    /* set file offset to current plus offset */
  72. #define    SEEK_END    2    /* set file offset to EOF plus offset */
  73.  
  74. /* Device switch */
  75. struct devsw {
  76.     char    *dv_name;
  77.     int    (*dv_strategy) __P((void *devdata, int rw,
  78.             daddr_t blk, u_int size, char *buf, u_int *rsize));
  79.     int    (*dv_open)();    /* (struct open_file *f, ...) */
  80.     int    (*dv_close) __P((struct open_file *f));
  81.     int    (*dv_ioctl) __P((struct open_file *f, int cmd, void *data));
  82. };
  83.  
  84. extern struct devsw devsw[];    /* device array */
  85. extern int ndevs;        /* number of elements in devsw[] */
  86.  
  87. struct open_file {
  88.     int        f_flags;    /* see F_* below */
  89.     struct devsw    *f_dev;        /* pointer to device operations */
  90.     void        *f_devdata;    /* device specific data */
  91.     struct fs_ops    *f_ops;        /* pointer to file system operations */
  92.     void        *f_fsdata;    /* file system specific data */
  93. };
  94.  
  95. #define    SOPEN_MAX    4
  96. extern struct open_file files[SOPEN_MAX];
  97.  
  98. /* f_flags values */
  99. #define    F_READ        0x0001    /* file opened for reading */
  100. #define    F_WRITE        0x0002    /* file opened for writing */
  101. #define    F_RAW        0x0004    /* raw device open - no file system */
  102.  
  103. int    devopen __P((struct open_file *f, char *fname, char **file));
  104. void    *alloc __P((unsigned size));
  105. void    free __P((void *ptr, unsigned size));
  106. struct    disklabel;
  107. char    *getdisklabel __P((const char *buf, struct disklabel *lp));
  108.